package com.project.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Controller
@RequestMapping("user")
public class UserController {

    //形如/user/del/1 的URL，由当前方法处理
    //将URL中的1赋值给userId变量，然后将userId变量的值赋给形参变量id
    @RequestMapping("del/{userId}")
    public void del(@PathVariable("userId") int id,
                    HttpServletResponse response) throws IOException {
        response.setContentType("text/html;charset=utf-8");
        response.getWriter().println("id="+id);
    }

    @RequestMapping("cutPage")
    public void cutPage(@RequestParam(value = "pageNO",defaultValue = "1") int pageNO, HttpServletResponse response)
        throws Exception{
        response.getWriter().println("pageNO="+pageNO);
    }
}
